home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Plug-In Power Pack for Netscape Communicator
/
Plug-In Power Pack for Netscape Communicator.iso
/
plugins
/
dataviews
/
dvdraw
/
examples
/
datasource
/
dstemplate.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1997-05-19
|
5KB
|
173 lines
/////////////////////////////////////////////////////////////////////////////
//
// DsTemplate.cpp : Starting point for a custom data source DLL
// for use with DV-Draw 9.8
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <afxdllx.h>
#include <afx.h>
#include "DvDsDll.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
static AFX_EXTENSION_MODULE MyDsDLL = { NULL, NULL };
/////////////////////////////////////////////////////////////////////////////
//
// CMyDsDll class
//
class CMyDsDll : public CDvDsDll
{
public :
void Release() { delete this; }
void GetIdInfo(CString& mfgName, CString& objName, CString& versionStr);
int HandleRequest(DV_DSDLLDATA* pData, CWnd* pParent);
};
/////////////////////////////////////////////////////////////////////////////
//
CMyDsDll::CMyDsDll()
{}
CMyDsDll::~CMyDsDll()
{}
/////////////////////////////////////////////////////////////////////////////
//
void CMyDsDll::GetIdInfo(CString& mfgName, CString& objName, CString& versionStr)
{
mfgName = "My Corporation";
objName = "My Data Browser";
versionStr = "1.0.0.1";
}
/////////////////////////////////////////////////////////////////////////////
//
int CMyDsDll::HandleRequest(DV_DSDLLDATA* pData, CWnd* pParent)
{
pData->m_Dirty = FALSE;
if(pData->m_Context & DV_DSDLL_QUERYDLL)
{
// Initial query request of what it is we support..
pData->m_Context = (DV_DSDLLCONTEXT)STD_SUPPORT;
return IDOK;
}
else if(pData->m_Context & DV_DSDLL_INITNEWVIEW)
{
// When DV-Draw first starts up, or when the user creates a 'New' view,
// DV-Draw gives the data DLL an opportunity to do anything it wants to
// the view. In the DataViews' standard browser, this code would create
// the 'default'dat' data source and a 'Var:1' data source variable.
}
else if(pData->m_Context & DV_DSDLL_RECONNECTDATA)
{
if(!pData->m_Sview)
// If no secondary view, then as you might expect, we just need to
// reconnect the vdp's to some place in the view. This really is only
// necessary if you are using dsvars, otherwise, if you are just storing
// information about your data connection in the vdp's name, then that
// has already been correctly cloned and you just need to perform any
// tasks specific to your data model.
else
{
// If there is a secondary view, we are pasting objects to another view
// altogether (this is the functional equivalent of 'Save subview').
// In DataViews' standard data browser, what is done is to clone the data
// sources into the secondary (target) view. You as the DLL writer will
// have to decide based on your specific needs what needs to be done.
}
}
else if(pData->m_Context & DV_DSDLL_DEFAULTDATA)
{
// Default data connection request. This called when graph or input
// objects are created (they are not created and then make a data
// connection later...its all done in oe shot). The only thing we need
// really pay attention to is the fact that input objects, even when drawn
// in the edit area, must have their vdp's attached to some persistent
// memory to write to or DV-Draw will crash!
if(pData->m_Context & DV_DSDLL_EDITINPUT)
// If necessary, attach the vdp to to some area of persistent memory
else
// Otherwise, tis a graph, so do whatever you need to do..
return IDOK;
}
else if(pData->m_Context & DV_DSDLL_EDITDSL ||
pData->m_Context & DV_DSDLL_SELECTDATA ||
pData->m_Context & DV_DSDLL_EXCHANGEDATA )
{
// Instantiate your dialog here abd call its DoModal() method:
//
// CMyDataDialog myDialog(...);
//
// if(myDialog.DoModal() == IDOK ) {
// ...
// }
//
// If dialog returns IDOK, then preform any necessary actions
// as required, for example, to you need to validate the type
// then of variable selected. Are you using data source variables?
// If so, and the context is DV_DSDLL_SELECTDATA or DV_DSDLL_EXCHANGEDATA
// make sure the pData->m_DsVar data member is set:
//
// pData->m_DsVar = myDialog.GetDsVar();
return IDOK;
}
return IDCANCEL;
}
extern "C" {
/////////////////////////////////////////////////////////////////////////////
//
DLLEXPORT BOOL
GetInterface(int idd, void **pInterf)
{
*pInterf = 0;
if (idd == IID_Datasource)
*pInterf = new CMyDsDll;
return (pInterf) ? TRUE : FALSE;
}
/////////////////////////////////////////////////////////////////////////////
//
int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
TRACE0("DSDLLTEMPLATE.DLL Initializing!\n");
// Extension DLL one-time initialization
AfxInitExtensionModule(MyDsDLL, hInstance);
// Insert this DLL into the resource chain
new CDynLinkLibrary(MyDsDLL);
}
else if (dwReason == DLL_PROCESS_DETACH)
{
TRACE0("DSDLLTEMPLATE.DLL Terminating!\n");
}
return 1; // ok
}
}